clear
set more off, perm
cd /Users/zachbrown/Projects/PriceTransparency/Data/


insheet using proc_codes/cpt_hcpc_code_lookup.csv, delim(",") names

rename hcpc_code_id proc_code

// Clean last updated variable
gen year = substr(last_updated,1,4)
destring year, replace
gen month = substr(last_updated,6,2)
destring month, replace
gen day = substr(last_updated,9,2)
destring day, replace
drop last_updated
gen last_updated = mdy(month,day,year)
format last_updated %td
drop month day year

drop if last_updated > mdy(1,1,2015)

// Save full
*save proc_codes/cms_cpt_codes_full.dta, replace

// Collapse
sort proc_code
by proc_code: egen cms_short_desc = mode(short_description)
by proc_code: egen cms_long_desc = mode(long_description)

mdesc cms_short_desc
mdesc cms_long_desc

keep proc_code cms_short_desc cms_long_desc
duplicates drop

gen cpt_in_ref = 0
compress
save proc_codes/cms_cpt_codes.dta, replace



